package com.jingjiu.homeservicesbiz.exception;


import com.jingjiu.homeservicesapi.enums.ResultEnum;
import com.jingjiu.homeservicesapi.util.R;
import org.springframework.http.HttpStatus;

/**
 * http异常
 *
 * @author Admin
 * @date 2023/07/21
 */
public class OlinkBaseException extends RuntimeException implements BaseResponse {

    protected int httpCode;
    protected int code;


    public OlinkBaseException() {
        super(ResultEnum.SYSTEM_EXCEPTION.getMsg());
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = ResultEnum.SYSTEM_EXCEPTION.getCode();
    }

    public OlinkBaseException(Exception e) {
        super(e.getMessage());
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = ResultEnum.SYSTEM_EXCEPTION.getCode();
    }


    public OlinkBaseException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = resultEnum.getCode();

    }


    public OlinkBaseException(String message) {
        super(message);
        this.httpCode = HttpStatus.INTERNAL_SERVER_ERROR.value();
        this.code = ResultEnum.SYSTEM_EXCEPTION.getCode();
    }


    @Override
    public int getHttpCode() {
        return this.httpCode;
    }

    @Override
    public int getCode() {
        return this.code;
    }
}